import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String A = in.nextLine();
        String B = in.nextLine();

        Set<String> hash1 = new HashSet<>();
        for(int i = 0; i < A.length(); i++) {
            for(int j = i + 1; j <= A.length(); j++) {
                hash1.add(A.substring(i, j));
            }
        }

        int ret = 0;
        //Set<String> hash2 = new HashSet<>();
        for(int i = 0; i < B.length(); i++) {
            for(int j = i + 1; j <= B.length(); j++) {
                //hash2.add(B.substring(i, j));
                String tmp = B.substring(i, j);
                if(hash1.contains(tmp)) {
                    if(i == 0 || j == B.length()) {
                        ret = Math.max(ret, tmp.length() + B.length() - A.length());
                    } else {
                        ret = Math.max(ret, tmp.length());
                    }
                }
            }
        }

        System.out.println(B.length() - ret);
    }
}